import random

sha_district = [
    '黄浦区',
    '静安区',
    '徐汇区',
    '长宁区',
    '杨浦区',
    '虹口区',
    '普陀区',
    '浦东新区',
    '宝山区',
    '嘉定区',
    '闵行区',
    '松江区',
    '青浦区',
    '奉贤区',
    '金山区'
]


def ran_district():
    """
    :return: 随机返回上海某区名称
    """
    return random.choice(sha_district)


def ran_address():
    """
    :return: 随机生成地址
    """
    result = '{0}路{1}弄{2}号{3}楼'
    road_name = ''
    for i in range(0, random.randint(2, 6)):
        road_name = road_name + ran_gbk()
    result = result.format(road_name, random.randint(1, 1000), random.randint(1, 1000), random.randint(1, 25))
    return result


def ran_gbk():
    """
    :return: 随机生成一个GBK汉字
    """
    head = random.randint(0xb0, 0xf7)
    body = random.randint(0xa1, 0xf9)  # 在head区号为55的那一块最后5个汉字是乱码,为了方便缩减下范围
    val = format('{head:x}{body:x}')
    result = bytes.fromhex(val).decode('gb2312')
    return result


def ran_float(min_input, max_input, number):
    """
    :return: 返回指定位数的浮点数
    """
    result = round(random.uniform(min_input, max_input), number)
    return result


def ran_store_full_name():
    """
    :return: 随机生成的店名
    """
    result = ''
    for i in range(0, random.randint(2, 6)):
        result = result + ran_gbk()
    title = ['超市', '大卖场', '便利店', '饭店', '大酒店', '商店']
    result = result + random.choice(title)
    return result


def ran_name():
    """
    :return: 随机生成的姓名
    """
    result = '{0}{1}'
    last_name = [
        '张', '李', '王', '马', '赵', '徐', '杨', '周', '陈', '吴', '朱'
    ]
    first_name = ''
    for i in range(0, random.randint(1, 2)):
        first_name = first_name + ran_gbk()
    result = result.format(random.choice(last_name), first_name)
    return result


def ran_contact_phone():
    """
    :return: 随机生成的手机号
    """
    result = '1'
    for i in range(0, 10):
        result = result + str(random.randint(0, 9))
    return result












